package com.neusoft.dibuy.orderby;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class PhoneDataDriver {


    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration cfg = new Configuration();
        Job job = Job.getInstance(cfg);

        job.setJarByClass(PhoneDataDriver.class);
        job.setMapperClass(PhoneDataMapper.class);
        job.setReducerClass(PhoneDataReducer.class);

        job.setMapOutputKeyClass(FlowBean.class);
        job.setMapOutputValueClass(Text.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowBean.class);


        // 6 设置输入和输出路径
        FileInputFormat.setInputPaths(job, "D:\\Dev\\hadoop-3.2.4\\work\\orderby\\input");
        FileOutputFormat.setOutputPath(job, new Path("D:\\Dev\\hadoop-3.2.4\\work\\orderby\\output7"));

        // 7 提交job
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);


    }
}
